<script setup>
import { ref } from 'vue'
import axios from 'axios'

// 绑定用户输入
const username = ref('')
const password = ref('')

const register = async () => {
  console.log('注册请求：', username.value, password.value)

  // 可选：发起注册请求（假设后端接口为 /v1/user/register）
  try {
    const res = await axios.post('http://localhost:8080/v1/users/register', {
      username: username.value,
      passwordHash: password.value
    })
    console.log('注册成功:', res.data)
  } catch (err) {
    console.error('注册失败:', err)
  }
}
</script>

<template>
  <div>
    <label>账号</label>
    <input type="text" v-model="username" placeholder="请输入账号" />

    <label>密码</label>
    <input type="password" v-model="password" placeholder="请输入密码" />

    <button @click="register">注册</button>
  </div>
</template>

<style scoped>
input {
  display: block;
  margin: 8px 0;
  padding: 4px;
}
button {
  margin-top: 10px;
}
</style>
